import {createApp} from 'vue';
import actHandlerTaskDialog from "./userActCommentDialog.vue";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

export function showDialog({required, autoDone}) {
    autoDone = autoDone === undefined ? true : autoDone;
    return new Promise(resolve => {
        let htmlDivElement = document.createElement("div");
        let elementApp = createApp(actHandlerTaskDialog, {
            required: required,
            onsubmit: function (value, done) {
                resolve({value, done})
                done()
            },
            onclose: function () {
                document.delete(htmlDivElement);
                elementApp.unmount()
            }
        });
        elementApp.use(ElementPlus)
        document.body.appendChild(htmlDivElement);
        elementApp.mount(htmlDivElement)
    });
}

const userActCommon = {
    showDialog
}
export default userActCommon